package com.dut.bbs.util;

public class StringUtils {
	public static String getReplyURL(String url){
		int i = url.lastIndexOf("/");
		String str1 = url.substring(0, i);
		String str2 = url.substring(i);
		String str = str1+"/post"+str2;
		return str;
	}
	//从开头截取字符串到指定字符
	public static String removeStr(String str,String text)
	{
	    int index = text.indexOf(str);
        if (index!=-1)
        {
            text = text.substring(0, index);
        }
        return text;
	}
	//从指定字符截取字符串到尾部
	public static String removeStr2(String str,String text){
		int index = text.indexOf(str);
		if (index!=-1)
        {
            text = text.substring(index+1);
        }
		return text;
	}
	//从文章url获取版面英文名
	public static String getBoard(String url){
		int i = url.lastIndexOf("/");
		String str1 = url.substring(0, i);
		int j = str1.lastIndexOf("/");
		return str1.substring(j+1);
	}
	//从版面url获取版面英文名
	public static String getBoard2(String url){
		int i = url.lastIndexOf("/");
		return url.substring(i+1);
	}
	public static String getBoradUrl(String board){
		return URLConstant.BOARD_URI_BASE+board;
	}
	public static String claerTitle(String str){
		if(str.length()<27)
			return str;
		else
			return str.substring(0, 24)+"...";
	}
	public static String getPostURL(String board){
		String str = URLConstant.POST_URI_BASE+board+"/post";
		return str;
	}
}
